/*
 * Inode.h
 *
 *  Created on: Mar 25, 2010
 *      Author: Lukasz Spintzyk
 */

#ifndef INODE_H_
#define INODE_H_

#include <linux/fs.h>
#include <ctime>

class DirEntry;
class DirectoryIterator;

#define DIRECT_LAST_INDEX 11
#define INDIRECT_1_INDEX 12
#define INDIRECT_2_INDEX 13
#define INDIRECT_3_INDEX 14


class Inode;
typedef boost::shared_ptr<Inode> InodePtr;

class Inode
{
public:
    ~Inode();

    void read(void* buffer);
    void write(void* buffer) const;
    bool testInode() const;

    friend class InodeManager;

    static uint32_t size();
    uint16_t d_mode;
    uint16_t d_uid;
    uint32_t d_size;
    time_t d_atime;
    time_t d_ctime;
    time_t d_mtime;
    time_t d_dtime;
    uint16_t d_gid;
    uint16_t d_linksCount;
    uint32_t d_flags;
    uint32_t d_blocks;
    uint32_t d_block[15];
    uint32_t d_osd1;
    //uint32_t d_generation;
    //probably not used
    uint32_t d_file_acl;
    uint32_t d_dir_acl;
    //uint32_t d_faddr;


    ///! transient variable
    uint32_t d_num;

//    Inode(const Inode&);

    Inode();
    bool isFile();
    bool isDir();
    bool isSymlink();
    bool isChrDev();
    bool isBlkDev();
    bool isFIFO();
    bool isSocket();

    static InodePtr newInstance();
    void initLinkInode(struct fuse_context* context);
    void initDirInode(struct fuse_context* context, mode_t mode);


   //sizeof inode =128

};



#endif /* INODE_H_ */
